package edu.tapestry.iddb.client.pages.userIDDB;

import iddb.AbstractResponse;
import iddb.OkResponse;

import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;

import edu.tapestry.iddb.client.entities.UserIDDB;
import edu.tapestry.iddb.client.pages.ErrorPage;
import edu.tapestry.iddb.client.pages.OKPage;
import edu.tapestry.iddb.client.webService.CommandsGenerator;
import edu.tapestry.iddb.client.webService.IDDBProxy;

public class LogoutUserIDDB {
	@Property
	private UserIDDB userIDDB;

	@ApplicationState
	private IDDBProxy proxy;
	
	
	
	@InjectPage
	private OKPage ok;
	
	@InjectPage
	private ErrorPage error;

	Object onActionFromLogout() {

		//*
		//proxy = new IDDBProxy();
		AbstractResponse resp = proxy.execute(CommandsGenerator.createLogout());

		if (resp instanceof OkResponse){
			return ok;
		}
		else {
			return error.initialize(resp);
		}
	}
	
	
}
